package com.singfan.app.controller;

import com.singfan.app.controller.model.HttpModelConverter;
import com.singfan.app.controller.model.ResponseModelBase;
import com.singfan.app.controller.model.request.*;
import com.singfan.app.controller.model.response.*;
import com.singfan.app.controller.model.response.partial.*;
import com.singfan.app.util.AppointmentUtil;
import com.singfan.app.util.RequestParamChecker;
import com.singfan.common.util.EncryptionUtil;
import com.singfan.common.util.JsonUtil;
import com.singfan.common.util.RandomUtil;
import com.singfan.common.util.StringUtil;
import com.singfan.core.component.BarberTokenHolder;
import com.singfan.core.component.CustomerTokenHolder;
import com.singfan.core.component.ShopTokenHolder;
import com.singfan.core.dao.database.model.*;
import com.singfan.core.dao.database.model.constant.*;
import com.singfan.core.service.IOrderService;
import com.singfan.core.service.IShopService;
import com.singfan.core.util.SmsUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.lang.String;
import java.util.*;

/**
 * Author: HanSongHe
 * Date: 2015-09-03 16:01
 * Desc:
 */
@Controller
public class BarberClientController extends SingFanControllerBase {

    @Autowired
    private IShopService shopService;
    @Autowired
    private IOrderService orderService;

    @RequestMapping(value="/v1/barber/securitycode", method=RequestMethod.POST)
    public void securityCode(HttpServletRequest request, HttpServletResponse response) {
        BarberSecurityCodeRequest barberSecurityCodeRequest = request2Bean(request, BarberSecurityCodeRequest.class);

        String securityCode = RandomUtil.randomNumber(6);
        String ip = getIpAddress(request);
        String phoneNumber = barberSecurityCodeRequest.getPhoneNumber();
        boolean sendResult = SmsUtil.sendSecurityCode(phoneNumber, securityCode);

        BarberSecurityCodeResponse result = new BarberSecurityCodeResponse();
        if (sendResult){
            barberService.createPhoneSecurityCode(phoneNumber, securityCode);
            result.setResultCode(ResultCode.SUCCESS);
            traceLog.debug(String.format("BarberClientController.securityCode() successful -> resultCode:%1$d, ip:%2$s, phoneNumber:%3$s, securityCode:%4$s", ResultCode.SUCCESS, ip, phoneNumber, securityCode));
        }
        else {
            result.setResultCode(ResultCode.SERVER_BUSY);
            traceLog.error(String.format("BarberClientController.securityCode() error with SERVER_BUSY -> resultCode:%1$d, ip:%2$s, phoneNumber:%3$s, securityCode:%4$s", ResultCode.REQUEST_PARAM_ERROR, ip, phoneNumber, securityCode));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/register", method= RequestMethod.POST)
    public void register(HttpServletRequest request, HttpServletResponse response) {
        BarberRegisterResponse result = new BarberRegisterResponse();
        BarberRegisterRequest barberRegisterRequest = request2Bean(request, BarberRegisterRequest.class);

        String ip = getIpAddress(request);
        String telNum = barberRegisterRequest.getTelNum();
        String securityCode = barberRegisterRequest.getSecurityCode();
        String pwd = barberRegisterRequest.getPwd();

        boolean checkResult = true;
        if (StringUtil.isNullOrEmpty(telNum)){
            checkResult = false;
        }
        else if (StringUtil.isNullOrEmpty(securityCode)){
            checkResult = false;
        }
        else if (StringUtil.isNullOrEmpty(pwd)){
            checkResult = false;
        }

        if (checkResult){
            boolean verifyResult = barberService.verifyPhoneSecurityCode(telNum, securityCode);
            if (verifyResult) {
                boolean isExist = barberService.isExist(telNum);
                if (!isExist){
                    Barber barber = barberService.create(telNum, securityCode, pwd);

                    String token = barberService.createAccessToken(barber.getId(), barber.getCityId(), barber.getStatus());
                    result.setResultCode(ResultCode.SUCCESS);
                    result.setAccessToken(token);

                    traceLog.debug(String.format("BarberClientController.register() successful -> resultCode:%1$d, ip:%2$s, telNum:%3$s, securityCode:%4$s, pwd:%5$s", ResultCode.SECURITY_CODE_ERROR, ip, telNum, securityCode, pwd));
                }
                else {
                    result.setResultCode(ResultCode.BARBER_PHONE_EXIST);
                    traceLog.error(String.format("BarberClientController.register() error with BARBER_PHONE_EXIST -> resultCode:%1$d, ip:%2$s, telNum:%3$s, securityCode:%4$s, pwd:%5$s", ResultCode.BARBER_PHONE_EXIST, ip, telNum, securityCode, pwd));
                }
            }
            else {
                result.setResultCode(ResultCode.SECURITY_CODE_ERROR);
                traceLog.error(String.format("BarberClientController.register() error with SECURITY_CODE_ERROR -> resultCode:%1$d, ip:%2$s, telNum:%3$s, securityCode:%4$s, pwd:%5$s", ResultCode.SECURITY_CODE_ERROR, ip, telNum, securityCode, pwd));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.register() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, telNum:%3$s, securityCode:%4$s, pwd:%5$s", ResultCode.REQUEST_PARAM_ERROR, ip, telNum, securityCode, pwd));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/forgetpwd", method= RequestMethod.POST)
    public void forgetPwd(HttpServletRequest request, HttpServletResponse response) {
        BarberForgetpwdResponse result = new BarberForgetpwdResponse();
        BarberForgetpwdRequest barberForgetpwdRequest = request2Bean(request, BarberForgetpwdRequest.class);

        String ip = getIpAddress(request);
        String telNum = barberForgetpwdRequest.getTelNum();
        String securityCode = barberForgetpwdRequest.getSecurityCode();
        String pwd = barberForgetpwdRequest.getPwd();

        boolean checkResult = true;
        if (StringUtil.isNullOrEmpty(telNum)){
            checkResult = false;
        }
        else if (StringUtil.isNullOrEmpty(securityCode)){
            checkResult = false;
        }
        else if (StringUtil.isNullOrEmpty(pwd)){
            checkResult = false;
        }

        if (checkResult){
            boolean verifyResult = barberService.verifyPhoneSecurityCode(telNum, securityCode);
            if (verifyResult){
                barberService.changePwd(telNum, pwd);
                Barber barber = barberService.findBarber(telNum);
                if (barber != null){
                    String token = barberService.createAccessToken(barber.getId(), barber.getCityId(), barber.getStatus());
                    result.setResultCode(ResultCode.SUCCESS);
                    result.setAccessToken(token);

                    traceLog.debug(String.format("BarberClientController.forgetPwd() successful -> resultCode:%1$d, ip:%2$s, telNum:%3$s, securityCode:%4$s, pwd:%5$s", ResultCode.SUCCESS, ip, telNum, securityCode, pwd));
                }
                else {
                    result.setResultCode(ResultCode.BARBER_NOT_EXIST);
                    traceLog.error(String.format("BarberClientController.forgetPwd() error with BARBER_NOT_EXIST -> resultCode:%1$d, ip:%2$s, telNum:%3$s, securityCode:%4$s, pwd:%5$s", ResultCode.BARBER_NOT_EXIST, ip, telNum, securityCode, pwd));
                }
            }
            else {
                result.setResultCode(ResultCode.SECURITY_CODE_ERROR);
                traceLog.error(String.format("BarberClientController.forgetPwd() error with SECURITY_CODE_ERROR -> resultCode:%1$d, ip:%2$s, telNum:%3$s, securityCode:%4$s, pwd:%5$s", ResultCode.SECURITY_CODE_ERROR, ip, telNum, securityCode, pwd));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.forgetPwd() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, telNum:%3$s, securityCode:%4$s, pwd:%5$s", ResultCode.REQUEST_PARAM_ERROR, ip, telNum, securityCode, pwd));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/shop/list", method= RequestMethod.POST)
    public void shopList(HttpServletRequest request, HttpServletResponse response) {
        BarberShopListResponse result = new BarberShopListResponse();

        String ip = getIpAddress(request);

        List<Shop> shopList = shopService.findAllShop();

        Map<Integer, String> masterShopNameMap = new HashMap<>();
        Map<Integer, List<String>> slaveShopListMap = new HashMap<>();

        for (Shop shop : shopList){
            if (!masterShopNameMap.containsKey(shop.getMasterShopId())){
                masterShopNameMap.put(shop.getMasterShopId(), shop.getMasterShopName());
            }

            if (!slaveShopListMap.containsKey(shop.getMasterShopId())){
                slaveShopListMap.put(shop.getMasterShopId(), new ArrayList<>());
            }

            slaveShopListMap.get(shop.getMasterShopId()).add(shop.getId() + "-" + shop.getSlaveShopName());
        }

        Set<Integer> shopIdSet = masterShopNameMap.keySet();
        List<BarberShopPartial> barberShopPartialList = new ArrayList<>(shopList.size());
        for (Integer masterShopId : shopIdSet){
            BarberShopPartial barberShopPartial = new BarberShopPartial();
            barberShopPartial.setShopMasterId(masterShopId);
            barberShopPartial.setShopMasterName(masterShopNameMap.get(masterShopId));
            barberShopPartial.setShopSlaveList(slaveShopListMap.get(masterShopId));

            barberShopPartialList.add(barberShopPartial);
        }
        result.setResultCode(ResultCode.SUCCESS);
        result.setBarberShopPartialList(barberShopPartialList);

        traceLog.debug(String.format("BarberClientController.shopList() successful -> resultCode:%1$d, ip:%2$s, listSize:%3$d", ResultCode.SECURITY_CODE_ERROR, ip, barberShopPartialList.size()));

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/register/detail", method= RequestMethod.POST)
    public void registerDetail(HttpServletRequest request, HttpServletResponse response) {
        BarberRegisterDetailResponse result = new BarberRegisterDetailResponse();
        BarberRegisterDetailRequest barberRegisterDetailRequest = request2Bean(request, BarberRegisterDetailRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberRegisterDetailRequest.getAccessToken();
        String avatar = barberRegisterDetailRequest.getAvatar();
        String nickName = barberRegisterDetailRequest.getNickName();
        int gender = barberRegisterDetailRequest.getGender();
        String address = barberRegisterDetailRequest.getAddress();
        String realName = barberRegisterDetailRequest.getRealName();
        String idCardNum = barberRegisterDetailRequest.getIdCardNum();
        long shopID = barberRegisterDetailRequest.getShopID();

        boolean checkResult = true;
        if (StringUtil.isNullOrEmpty(avatar) || avatar.length() > 256){
            checkResult = false;
        }
        else if (StringUtil.isNullOrEmpty(nickName) || nickName.length() > 32) {
            checkResult = false;
        }
        else if(StringUtil.isNullOrEmpty(realName) || realName.length() > 32) {
            checkResult = false;
        }
        else if(StringUtil.isNullOrEmpty(idCardNum) || idCardNum.length() != 18) {
            checkResult = false;
        }
        else if(StringUtil.isNullOrEmpty(address) || address.length() > 256) {
            checkResult = false;
        }
        else if(!GenderType.isGenderType(gender)) {
            checkResult = false;
        }

        if (checkResult){
            long barberId = getBarberId();
            if (barberId > 0){
                Barber barber = barberService.findBarber(barberId);
                if (barber != null && barber.getStatus() != BusinessStatusType.VERIFY_PASSED){
                    barber.setAvatar(avatar);
                    barber.setNickName(nickName);
                    barber.setGender(gender);
                    barber.setAddress(address);
                    barber.setRealName(realName);
                    barber.setIdCardNumber(idCardNum);
                    ShopHair shopHair = shopService.findShopHair(shopID);
                    if (shopHair != null){
                        barber.setShopId(shopID);
                        barber.setLongitude(shopHair.getLongitude());
                        barber.setLatitude(shopHair.getLatitude());
                        barber.setMasterShopName(shopHair.getMasterShopName());
                        barber.setSlaveShopName(shopHair.getSlaveShopName());
                        barberService.updateBarberDetail(barber);

                        result.setResultCode(ResultCode.SUCCESS);
                        traceLog.debug(String.format("BarberClientController.registerDetail() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, avatar:%4$s, nickName:%5$s, gender:%6$d, address:%7$s, realName:%8$s, idCardNum:%9$s, shopID:%10$d", ResultCode.SUCCESS, ip, accessToken, avatar, nickName, gender, address, realName, idCardNum, shopID));
                    }
                    else {
                        result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
                        traceLog.error(String.format("BarberClientController.registerDetail() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, avatar:%4$s, nickName:%5$s, gender:%6$d, address:%7$s, realName:%8$s, idCardNum:%9$s, shopID:%10$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, avatar, nickName, gender, address, realName, idCardNum, shopID));
                    }
                }
                else {
                    result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
                    traceLog.error(String.format("BarberClientController.registerDetail() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, avatar:%4$s, nickName:%5$s, gender:%6$d, address:%7$s, realName:%8$s, idCardNum:%9$s, shopID:%10$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, avatar, nickName, gender, address, realName, idCardNum, shopID));
                }
            }
            else {
                result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
                traceLog.error(String.format("BarberClientController.registerDetail() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, avatar:%4$s, nickName:%5$s, gender:%6$d, address:%7$s, realName:%8$s, idCardNum:%9$s, shopID:%10$d", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken, avatar, nickName, gender, address, realName, idCardNum, shopID));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.registerDetail() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, avatar:%4$s, nickName:%5$s, gender:%6$d, address:%7$s, realName:%8$s, idCardNum:%9$s, shopID:%10$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, avatar, nickName, gender, address, realName, idCardNum, shopID));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/person/detail", method= RequestMethod.POST)
    public void personDetail(HttpServletRequest request, HttpServletResponse response) {
        BarberPersonDetailResponse result = new BarberPersonDetailResponse();
        BarberPersonDetailRequest barberPersonDetailRequest = request2Bean(request, BarberPersonDetailRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberPersonDetailRequest.getAccessToken();
        long barberId = getBarberId();

        if (barberId > 0){
            result.setResultCode(ResultCode.SUCCESS);
            Barber barber = barberService.findBarber(barberId);
            result.setAvatar(barber.getAvatar());
            result.setNickName(barber.getNickName());
            result.setGender(barber.getGender());
            result.setAddress(barber.getAddress());
            result.setRealName(barber.getRealName());
            result.setIdCardNum(barber.getIdCardNumber());
            result.setShopID(barber.getShopId());
            result.setShopMasterName(barber.getMasterShopName());
            result.setShopSlaveName(barber.getSlaveShopName());
            result.setPhoneNum(barber.getPhoneNumber());
            if (barber.getStatus() == BusinessStatusType.VERIFY_PASSED){
                result.setChange(false);
            }
            else {
                result.setChange(true);
            }

            traceLog.debug(String.format("BarberClientController.personDetail() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s", ResultCode.SUCCESS, ip, accessToken));
        }
        else {
            result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
            traceLog.error(String.format("BarberClientController.personDetail() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/person/update", method= RequestMethod.POST)
    public void registerUpdate(HttpServletRequest request, HttpServletResponse response) {
        BarberPersonDetailUpdateResponse result = new BarberPersonDetailUpdateResponse();
        BarberPersonDetailUpdateRequest barberPersonDetailUpdateRequest = request2Bean(request, BarberPersonDetailUpdateRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberPersonDetailUpdateRequest.getAccessToken();
        String avatar = barberPersonDetailUpdateRequest.getAvatar();
        String nickName = barberPersonDetailUpdateRequest.getNickName();
        int gender = barberPersonDetailUpdateRequest.getGender();
        String address = barberPersonDetailUpdateRequest.getAddress();
        String realName = barberPersonDetailUpdateRequest.getRealName();
        String idCardNum = barberPersonDetailUpdateRequest.getIdCardNum();
        long shopID = barberPersonDetailUpdateRequest.getShopID();

        boolean checkResult = true;
        if (StringUtil.isNullOrEmpty(avatar) || avatar.length() > 256){
            checkResult = false;
        }
        else if (StringUtil.isNullOrEmpty(nickName) || nickName.length() > 32) {
            checkResult = false;
        }
        else if(StringUtil.isNullOrEmpty(realName) || realName.length() > 32) {
            checkResult = false;
        }
        else if(StringUtil.isNullOrEmpty(idCardNum) || idCardNum.length() != 18) {
            checkResult = false;
        }
        else if(StringUtil.isNullOrEmpty(address) || address.length() > 256) {
            checkResult = false;
        }
        else if(!GenderType.isGenderType(gender)) {
            checkResult = false;
        }

        if (checkResult){
            long barberId = getBarberId();
            if (barberId > 0){
                Barber barber = barberService.findBarber(barberId);
                if (barber != null && barber.getStatus() != BusinessStatusType.VERIFY_PASSED){
                    barber.setAvatar(avatar);
                    barber.setNickName(nickName);
                    barber.setGender(gender);
                    barber.setAddress(address);
                    barber.setRealName(realName);
                    barber.setIdCardNumber(idCardNum);
                    ShopHair shopHair = shopService.findShopHair(shopID);
                    if (shopHair != null){
                        barber.setShopId(shopID);
                        barber.setLongitude(shopHair.getLongitude());
                        barber.setLatitude(shopHair.getLatitude());
                        barberService.updateBarberDetail(barber);

                        result.setResultCode(ResultCode.SUCCESS);
                        traceLog.debug(String.format("BarberClientController.registerUpdate() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, avatar:%4$s, nickName:%5$s, gender:%6$d, address:%7$s, realName:%8$s, idCardNum:%9$s, shopID:%10$d", ResultCode.SUCCESS, ip, accessToken, avatar, nickName, gender, address, realName, idCardNum, shopID));
                    }
                    else {
                        result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
                        traceLog.error(String.format("BarberClientController.registerUpdate() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, avatar:%4$s, nickName:%5$s, gender:%6$d, address:%7$s, realName:%8$s, idCardNum:%9$s, shopID:%10$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, avatar, nickName, gender, address, realName, idCardNum, shopID));
                    }
                }
                else {
                    result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
                    traceLog.error(String.format("BarberClientController.registerUpdate() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, avatar:%4$s, nickName:%5$s, gender:%6$d, address:%7$s, realName:%8$s, idCardNum:%9$s, shopID:%10$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, avatar, nickName, gender, address, realName, idCardNum, shopID));
                }
            }
            else {
                result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
                traceLog.error(String.format("BarberClientController.registerUpdate() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, avatar:%4$s, nickName:%5$s, gender:%6$d, address:%7$s, realName:%8$s, idCardNum:%9$s, shopID:%10$d", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken, avatar, nickName, gender, address, realName, idCardNum, shopID));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.registerUpdate() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, avatar:%4$s, nickName:%5$s, gender:%6$d, address:%7$s, realName:%8$s, idCardNum:%9$s, shopID:%10$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, avatar, nickName, gender, address, realName, idCardNum, shopID));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/login", method= RequestMethod.POST)
    public void login(HttpServletRequest request, HttpServletResponse response) {
        BarberLoginResponse result = new BarberLoginResponse();
        BarberLoginRequest barberLoginRequest = request2Bean(request, BarberLoginRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberLoginRequest.getAccessToken();

        String phoneNumber = barberLoginRequest.getPhoneNumber();
        String pwd = barberLoginRequest.getPwd();

        boolean checkResult = true;
        if (StringUtil.isNullOrEmpty(phoneNumber)){
            checkResult = false;
        }
        else if (StringUtil.isNullOrEmpty(pwd)){
            checkResult = false;
        }

        if (checkResult){
            Barber barber = barberService.findBarber(phoneNumber);
            if (barber != null){
                if (barber.getStatus() != BusinessStatusType.FORBIDDEN){
                    String password = EncryptionUtil.md5(pwd + "-" + barber.getPasswordSalt());
                    if (password.equals(barber.getPassword())){
                        String token = barberService.createAccessToken(barber.getId(), barber.getCityId(), barber.getStatus());
                        result.setResultCode(ResultCode.SUCCESS);
                        result.setPhoneNumber(barber.getPhoneNumber());
                        result.setAvatar(barber.getAvatar());
                        result.setAccessToken(token);
                        traceLog.debug(String.format("BarberClientController.login() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, phoneNumber:%4$s, pwd:%5$s", ResultCode.SUCCESS, ip, accessToken, phoneNumber, pwd));
                    }
                    else {
                        result.setResultCode(ResultCode.BARBER_PWD_ERROR);
                        traceLog.error(String.format("BarberClientController.login() error with BARBER_PWD_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, phoneNumber:%4$s, pwd:%5$s", ResultCode.BARBER_PWD_ERROR, ip, accessToken, phoneNumber, pwd));
                    }
                }
                else {
                    result.setResultCode(ResultCode.ACCOUNT_DISABLED);
                    traceLog.error(String.format("BarberClientController.login() error with ACCOUNT_DISABLED -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, phoneNumber:%4$s, pwd:%5$s", ResultCode.ACCOUNT_DISABLED, ip, accessToken, phoneNumber, pwd));
                }
            }
            else {
                result.setResultCode(ResultCode.BARBER_NOT_EXIST);
                traceLog.error(String.format("BarberClientController.login() error with BARBER_NOT_EXIST -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, phoneNumber:%4$s, pwd:%5$s", ResultCode.BARBER_NOT_EXIST, ip, accessToken, phoneNumber, pwd));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.login() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, phoneNumber:%4$s, pwd:%5$s", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, phoneNumber, pwd));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/home", method= RequestMethod.POST)
    public void home(HttpServletRequest request, HttpServletResponse response) {
        BarberHomeResponse result = new BarberHomeResponse();
        BarberHomeRequest barberHomeRequest = request2Bean(request, BarberHomeRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberHomeRequest.getAccessToken();
        long barberId = getBarberId();

        if (barberId > 0){
            int orderCount = orderService.barberOrderCount(barberId);
            int orderUnfinishCount = orderService.barberUnfinishOrderCount(barberId);
            Barber barber = barberService.findBarber(barberId);

            result.setOrderCount(orderCount);
            result.setOrderUnFinishCount(orderUnfinishCount);
            result.setGoodCommentCount(barber.getFavorableCommentCount());
            result.setBadCommentCount(barber.getCommentCount() - barber.getFavorableCommentCount());
            if (barber.getCommentCount() > 0){
                result.setGoodCommentRatio((barber.getFavorableCommentCount() * 100) / barber.getCommentCount());
            }
            else{
                result.setGoodCommentRatio(0);
            }

            result.setResultCode(ResultCode.SUCCESS);
            traceLog.debug(String.format("BarberClientController.home() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s", ResultCode.SUCCESS, ip, accessToken));
        }
        else {
            result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
            traceLog.error(String.format("BarberClientController.home() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/worksrank", method= RequestMethod.POST)
    public void worksRank(HttpServletRequest request, HttpServletResponse response) {
        BarberWorksRankResponse result = new BarberWorksRankResponse();
        BarberWorksRankRequest barberWorksRankRequest = request2Bean(request, BarberWorksRankRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberWorksRankRequest.getAccessToken();
        int listOrderType = barberWorksRankRequest.getListOrderType();
        int pageIndex = barberWorksRankRequest.getPageIndex();
        int pageSize = barberWorksRankRequest.getPageSize();

        boolean checkResult = true;
        if (listOrderType != 1 && listOrderType != 2){
            checkResult = false;
        }
        else if(!RequestParamChecker.checkPageIndexAndSize(pageIndex, pageSize)){
            checkResult = false;
        }

        if (checkResult){
            long barberId = getBarberId();

            if (barberId > 0){
                if (pageIndex == 0){
                    result.setNewList(true);
                }
                else {
                    result.setNewList(false);
                }

                List<BarberHairstyle> barberHairstyleList;
                if (listOrderType == 1){
                    barberHairstyleList = barberService.findBarberHairstyleByFavorable(pageIndex, pageSize);
                }
                else{
                    barberHairstyleList = barberService.findBarberHairstyleByTime(pageIndex, pageSize);
                }
                List<HairstylePartial> hairstylePartialList = new ArrayList<>();
                for (BarberHairstyle barberHairstyle : barberHairstyleList){
                    HairstylePartial hairstylePartial = HttpModelConverter.barberHairstyle2HairstylePartial(barberHairstyle);
                    hairstylePartialList.add(hairstylePartial);
                }
                result.setHairstyleList(hairstylePartialList);

                result.setResultCode(ResultCode.SUCCESS);
                traceLog.debug(String.format("BarberClientController.worksRank() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, listOrderType:%4$d, pageIndex:%5$d, pageSize:%6$d", ResultCode.SUCCESS, ip, accessToken, listOrderType, pageIndex, pageSize));
            }
            else {
                result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
                traceLog.error(String.format("BarberClientController.worksRank() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, listOrderType:%4$d, pageIndex:%5$d, pageSize:%6$d", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken, listOrderType, pageIndex, pageSize));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.worksRank() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, listOrderType:%4$d, pageIndex:%5$d, pageSize:%6$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, listOrderType, pageIndex, pageSize));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/worksrank/detail", method= RequestMethod.POST)
    public void worksRankDetail(HttpServletRequest request, HttpServletResponse response) {
        BarberWorksRankDetailResponse result = new BarberWorksRankDetailResponse();
        BarberWorksRankDetailRequest barberWorksRankDetailRequest = request2Bean(request, BarberWorksRankDetailRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberWorksRankDetailRequest.getAccessToken();
        long hairstyleId = barberWorksRankDetailRequest.getHairstyleID();

        BarberHairstyle barberHairstyle = barberService.findBarberHairstyle(hairstyleId);
        if (barberHairstyle != null){
            Barber barber = barberService.findBarber(barberHairstyle.getBarberId());
            result.setHairstyleID(barberHairstyle.getId());
            result.setHairstyleName(barberHairstyle.getHairstyleName());
            result.setHairstylePrice(barberHairstyle.getPrice());
            result.setHairstyleImgUrlList(StringUtil.split(barberHairstyle.getImgList(), ";"));
            result.setOrderCount(barberHairstyle.getOrderCount());
            result.setHairstyleDesc(barberHairstyle.getHairstyleDesc());
            result.setBarberPartial(HttpModelConverter.barber2BarberPartial(barber));

            traceLog.debug(String.format("worksRankDetail.worksRankDetail() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d", ResultCode.SUCCESS, ip, accessToken, hairstyleId));
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("worksRankDetail.worksRankDetail() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, hairstyleId));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myworks", method= RequestMethod.POST)
    public void myWorks(HttpServletRequest request, HttpServletResponse response) {
        BarberMyWorksResponse result = new BarberMyWorksResponse();
        BarberMyWorksRequest barberMyWorksRequest = request2Bean(request, BarberMyWorksRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyWorksRequest.getAccessToken();
        int pageIndex = barberMyWorksRequest.getPageIndex();
        int pageSize = barberMyWorksRequest.getPageSize();
        int status = barberMyWorksRequest.getStatus();

        if(RequestParamChecker.checkPageIndexAndSize(pageIndex, pageSize) && BusinessStatusType.isBusinessStatusType(status)){
            long barberId = getBarberId();

            if (barberId > 0){
                if (pageIndex == 0){
                    result.setNewList(true);
                }
                else {
                    result.setNewList(false);
                }

                List<BarberHairstyle> barberHairstyleList = barberService.findBarberSelfHairstyleList(barberId, pageIndex, pageSize, status);
                List<HairstylePartial> hairstylePartialList = new ArrayList<>();
                for (BarberHairstyle barberHairstyle : barberHairstyleList){
                    HairstylePartial hairstylePartial = HttpModelConverter.barberHairstyle2HairstylePartial(barberHairstyle);
                    hairstylePartialList.add(hairstylePartial);
                }
                result.setHairstyleList(hairstylePartialList);

                result.setResultCode(ResultCode.SUCCESS);
                traceLog.debug(String.format("BarberClientController.myWorks() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, pageIndex:%4$d, pageSize:%5$d, status:%6$d", ResultCode.SUCCESS, ip, accessToken, pageIndex, pageSize, status));
            }
            else {
                result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
                traceLog.error(String.format("BarberClientController.myWorks() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, pageIndex:%4$d, pageSize:%5$d, status:%6$d", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken, pageIndex, pageSize, status));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.myWorks() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, pageIndex:%4$d, pageSize:%5$d, status:%6$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, pageIndex, pageSize, status));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myworks/detail", method= RequestMethod.POST)
    public void myWorksDetail(HttpServletRequest request, HttpServletResponse response) {
        BarberMyWorksDetailResponse result = new BarberMyWorksDetailResponse();
        BarberMyWorksDetailRequest barberMyWorksDetailRequest = request2Bean(request, BarberMyWorksDetailRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyWorksDetailRequest.getAccessToken();
        long hairstyleId = barberMyWorksDetailRequest.getHairstyleID();
        long barberId = getBarberId();

        if (barberId > 0){
            BarberHairstyle barberHairstyle = barberService.findBarberHairstyle(hairstyleId);
            if (barberHairstyle != null && barberHairstyle.getBarberId() == barberId){
                result.setResultCode(ResultCode.SUCCESS);
                result.setHairstyleID(hairstyleId);
                result.setHairstyleName(barberHairstyle.getHairstyleName());
                result.setHairstylePrice(barberHairstyle.getPrice());
                result.setHairstyleImgUrlList(StringUtil.split(barberHairstyle.getImgList(), ";"));
                result.setOrderCount(barberHairstyle.getOrderCount());
                result.setHairstyleDesc(barberHairstyle.getHairstyleDesc());
                result.setGender(barberHairstyle.getGender());
                result.setStatus(barberHairstyle.getStatus());

                traceLog.debug(String.format("BarberClientController.myWorksDetail() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d", ResultCode.SUCCESS, ip, accessToken, hairstyleId));
            }
            else {
                result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
                traceLog.error(String.format("BarberClientController.myWorksDetail() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, hairstyleId));
            }
        }
        else {
            result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
            traceLog.error(String.format("BarberClientController.myWorksDetail() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken, hairstyleId));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myworks/add", method= RequestMethod.POST)
    public void myWorksAdd(HttpServletRequest request, HttpServletResponse response) {
        BarberMyWorksAddResponse result = new BarberMyWorksAddResponse();
        BarberMyWorksAddRequest barberMyWorksAddRequest = request2Bean(request, BarberMyWorksAddRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyWorksAddRequest.getAccessToken();
        String hairstyleName = barberMyWorksAddRequest.getHairstyleName();
        int hairstylePrice = barberMyWorksAddRequest.getHairstylePrice();
        List<String> hairstyleImgUrlList = barberMyWorksAddRequest.getHairstyleImgUrlList();
        String hairstyleDesc = barberMyWorksAddRequest.getHairstyleDesc();
        int gender = barberMyWorksAddRequest.getGender();

        long barberId = getBarberId();

        if (isPassedBarber()){
            boolean checkResult = true;
            if (StringUtil.isNullOrEmpty(hairstyleName) || hairstyleName.length() > 64){
                checkResult = false;
            }
            else if (StringUtil.isNullOrEmpty(hairstyleDesc) || hairstyleDesc.length() > 512) {
                checkResult = false;
            }
            else if(hairstylePrice <= 0) {
                checkResult = false;
            }
            else if(hairstyleImgUrlList == null || hairstyleImgUrlList.size() == 0) {
                checkResult = false;
            }
            else if(gender<1 || gender>3){
                checkResult = false;
            }

            if (checkResult){
                Barber barber = barberService.findBarber(barberId);
                Shop shop = shopService.findShop(barber.getShopId());

                BarberHairstyle barberHairstyle = new BarberHairstyle();

                String imgUrls = "";
                barberHairstyle.setPreferredImg(hairstyleImgUrlList.get(0));
                for(String url : hairstyleImgUrlList){
                    imgUrls += url + ";";
                }
                imgUrls = imgUrls.substring(0, imgUrls.length() -1);

                barberHairstyle.setImgList(imgUrls);
                barberHairstyle.setBarberId(barberId);
                barberHairstyle.setBarberName(barber.getNickName());
                barberHairstyle.setCityId(shop.getCityId());
                barberHairstyle.setBusinessCircleId(shop.getBusinessCircleId());
                barberHairstyle.setLongitude(shop.getLongitude());
                barberHairstyle.setLatitude(shop.getLatitude());
                barberHairstyle.setHairstyleName(hairstyleName);
                barberHairstyle.setPrice(hairstylePrice);
                barberHairstyle.setGender(gender);
                barberHairstyle.setOrderCount(0);
                barberHairstyle.setCollectCount(0);
                barberHairstyle.setHairstyleDesc(hairstyleDesc);
                barberHairstyle.setStatus(0);
                barberHairstyle.setCreateTime(new Date());

                barberService.createBarberHairstyle(barberHairstyle);

                result.setResultCode(ResultCode.SUCCESS);

                traceLog.debug(String.format("BarberClientController.myWorksAdd() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleName:%4$s, hairstylePrice:%5$s, hairstyleDesc:%6$s, gender:%7$d", ResultCode.SUCCESS, ip, accessToken, hairstyleName, hairstylePrice, hairstyleDesc, gender));
            }
            else{
                result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
                traceLog.error(String.format("BarberClientController.myWorksAdd() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleName:%4$s, hairstylePrice:%5$s, hairstyleDesc:%6$s, gender:%7$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, hairstyleName, hairstylePrice, hairstyleDesc, gender));
            }

        }
        else {
            result.setResultCode(ResultCode.BARBER_CHECKING);
            traceLog.error(String.format("BarberClientController.myWorksAdd() error with BARBER_CHECKING -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleName:%4$s, hairstylePrice:%5$s, hairstyleDesc:%6$s, gender:%7$d", ResultCode.BARBER_CHECKING, ip, accessToken, hairstyleName, hairstylePrice, hairstyleDesc, gender));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myworks/save", method= RequestMethod.POST)
    public void myWorksSave(HttpServletRequest request, HttpServletResponse response) {
        BarberMyWorksSaveResponse result = new BarberMyWorksSaveResponse();
        BarberMyWorksSaveRequest barberMyWorksSaveRequest = request2Bean(request, BarberMyWorksSaveRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyWorksSaveRequest.getAccessToken();
        long hairstyleId = barberMyWorksSaveRequest.getHairstyleID();
        String hairstyleName = barberMyWorksSaveRequest.getHairstyleName();
        int hairstylePrice = barberMyWorksSaveRequest.getHairstylePrice();
        List<String> hairstyleImgUrlList = barberMyWorksSaveRequest.getHairstyleImgUrlList();
        String hairstyleDesc = barberMyWorksSaveRequest.getHairstyleDesc();
        int gender = barberMyWorksSaveRequest.getGender();
        long barberId = getBarberId();

        if (barberId > 0){
            BarberHairstyle barberHairstyle = barberService.findBarberHairstyle(hairstyleId);
            if (barberHairstyle != null && barberHairstyle.getBarberId() == barberId &&(gender>=1 && gender<=3)){
                barberHairstyle.setHairstyleName(hairstyleName);
                barberHairstyle.setPrice(hairstylePrice);
                String imgUrls = "";
                if (hairstyleImgUrlList != null && hairstyleImgUrlList.size() > 0){
                    for(String url : hairstyleImgUrlList){
                        imgUrls += url + ";";
                    }
                    imgUrls = imgUrls.substring(0, imgUrls.length() -1);
                }
                barberHairstyle.setImgList(imgUrls);
                barberHairstyle.setHairstyleDesc(hairstyleDesc);
                barberHairstyle.setGender(gender);
                barberService.updateHairstyle(barberHairstyle);

                result.setResultCode(ResultCode.SUCCESS);

                traceLog.debug(String.format("BarberClientController.myWorksSave() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d, hairstyleName:%5$s, hairstylePrice:%6$s, hairstyleDesc:%7$s", ResultCode.SUCCESS, ip, accessToken, hairstyleId, hairstyleName, hairstylePrice, hairstyleDesc));
            }
            else {
                result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
                traceLog.error(String.format("BarberClientController.myWorksSave() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d, hairstyleName:%5$s, hairstylePrice:%6$s, hairstyleDesc:%7$s", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, hairstyleId, hairstyleName, hairstylePrice, hairstyleDesc));
            }
        }
        else {
            result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
            traceLog.error(String.format("BarberClientController.myWorksSave() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d, hairstyleName:%5$s, hairstylePrice:%6$s, hairstyleDesc:%7$s", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken, hairstyleId, hairstyleName, hairstylePrice, hairstyleDesc));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myworks/delete", method= RequestMethod.POST)
    public void myWorksDelete(HttpServletRequest request, HttpServletResponse response) {
        BarberMyWorksDeleteResponse result = new BarberMyWorksDeleteResponse();
        BarberMyWorksDeleteRequest barberMyWorksDeleteRequest = request2Bean(request, BarberMyWorksDeleteRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyWorksDeleteRequest.getAccessToken();
        long hairstyleId = barberMyWorksDeleteRequest.getHairstyleID();
        long barberId = getBarberId();

        if (barberId > 0){
            BarberHairstyle barberHairstyle = barberService.findBarberHairstyle(hairstyleId);
            if (barberHairstyle != null && barberHairstyle.getBarberId() == barberId){
                barberService.deleteBarberHairstyle(barberId, hairstyleId);
                result.setResultCode(ResultCode.SUCCESS);

                traceLog.debug(String.format("BarberClientController.myWorksDelete() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d", ResultCode.SUCCESS, ip, accessToken, hairstyleId));
            }
            else {
                result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
                traceLog.error(String.format("BarberClientController.myWorksDelete() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, hairstyleId));
            }
        }
        else {
            result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
            traceLog.error(String.format("BarberClientController.myWorksDelete() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, hairstyleId:%4$d", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken, hairstyleId));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myappointment", method= RequestMethod.POST)
    public void myAppointment(HttpServletRequest request, HttpServletResponse response) {
        BarberMyAppointmentResponse result = new BarberMyAppointmentResponse();
        BarberMyAppointmentRequest barberMyAppointmentRequest = request2Bean(request, BarberMyAppointmentRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyAppointmentRequest.getAccessToken();
        int dayTime = barberMyAppointmentRequest.getDayTime();

        if (RequestParamChecker.checkAppointmentDayTime(dayTime)){
            if (isPassedBarber()){
                List<BarberAppointment> appointmentList = barberService.findBarberAppointmentListByDayTime(getBarberId(), dayTime);
                List<AppointmentPartial> appointmentPartialList = AppointmentUtil.getAppointmentPartialList(dayTime, appointmentList);
                result.setAppointmentList(appointmentPartialList);

                result.setResultCode(ResultCode.SUCCESS);
                traceLog.debug(String.format("BarberClientController.myAppointment() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, dayTime:%4$d", ResultCode.SUCCESS, ip, accessToken, dayTime));
            }
            else {
                result.setResultCode(ResultCode.BARBER_CHECKING);
                traceLog.error(String.format("BarberClientController.myAppointment() error with BARBER_CHECKING -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, dayTime:%4$d", ResultCode.BARBER_CHECKING, ip, accessToken, dayTime));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.myAppointment() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, dayTime:%4$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, dayTime));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myappointment/rest", method= RequestMethod.POST)
    public void myAppointmentRest(HttpServletRequest request, HttpServletResponse response) {
        BarberMyAppointmentRestResponse result = new BarberMyAppointmentRestResponse();
        BarberMyAppointmentRestRequest barberMyAppointmentRestRequest = request2Bean(request, BarberMyAppointmentRestRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyAppointmentRestRequest.getAccessToken();
        int dayTime = barberMyAppointmentRestRequest.getDayTime();
        int clockTime = barberMyAppointmentRestRequest.getClockTime();
        boolean activeType = barberMyAppointmentRestRequest.isActiveType();

        int todayTime = AppointmentUtil.getTodayTime();

        if (RequestParamChecker.checkAppointmentDayTime(dayTime) && RequestParamChecker.checkAppointmentClockTime(clockTime) && dayTime >= todayTime){
            if (isPassedBarber()){
                long barberId = getBarberId();
                BarberAppointment barberAppointment = barberService.findBarberAppointment(barberId, dayTime, clockTime);
                if (activeType){
                    if (barberAppointment != null){
                        if (barberAppointment.getOrderId() > 0){
                            result.setActiveResult(false);
                        }
                        else {
                            result.setActiveResult(true);
                        }
                    }
                    else {
                        barberService.createRestAppointment(barberId, dayTime, clockTime);
                        result.setActiveResult(true);
                    }
                }
                else {
                    if (barberAppointment != null){
                        if (barberAppointment.getOrderId() < 0){
                            barberService.deleteAppointment(barberId, dayTime, clockTime);
                            result.setActiveResult(true);
                        }
                        else {
                            result.setActiveResult(false);
                        }
                    }
                    else {
                        result.setActiveResult(true);
                    }
                }


                result.setResultCode(ResultCode.SUCCESS);
                traceLog.debug(String.format("BarberClientController.myAppointmentRest() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, dayTime:%4$d, clockTime:%5$d, activeType:%6$b", ResultCode.SUCCESS, ip, accessToken, dayTime, clockTime, activeType));
            }
            else {
                result.setResultCode(ResultCode.BARBER_CHECKING);
                traceLog.error(String.format("BarberClientController.myAppointmentRest() error with BARBER_CHECKING -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, dayTime:%4$d, clockTime:%5$d, activeType:%6$b", ResultCode.BARBER_CHECKING, ip, accessToken, dayTime, clockTime, activeType));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.myAppointmentRest() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, dayTime:%4$d, clockTime:%5$d, activeType:%6$b", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, dayTime, clockTime, activeType));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myappointment/batchset", method= RequestMethod.POST)
    public void myAppointmentBatchset(HttpServletRequest request, HttpServletResponse response) {
        BarberMyAppointmentBatchSetResponse result = new BarberMyAppointmentBatchSetResponse();
        BarberMyAppointmentBatchSetRequest barberMyAppointmentBatchSetRequest = request2Bean(request, BarberMyAppointmentBatchSetRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyAppointmentBatchSetRequest.getAccessToken();
        int dayTime = barberMyAppointmentBatchSetRequest.getDayTime();
        int periodTime = barberMyAppointmentBatchSetRequest.getPeriodTime();
        boolean activeType = barberMyAppointmentBatchSetRequest.isActiveType();

        if (RequestParamChecker.checkAppointmentDayTime(dayTime) && periodTime >= 1 && periodTime <= 3){
            if (isPassedBarber()){
                long barberId = getBarberId();
                List<Integer> appointmentClockList = AppointmentUtil.createPeriodAppointmentList(periodTime);
                for (Integer clockTime : appointmentClockList){
                    BarberAppointment barberAppointment = barberService.findBarberAppointment(barberId, dayTime, clockTime);
                    if (activeType){
                        if (barberAppointment == null){
                            barberService.createRestAppointment(barberId, dayTime, clockTime);
                        }
                    }
                    else {
                        if (barberAppointment != null){
                            if (barberAppointment.getOrderId() < 0){
                                barberService.deleteAppointment(barberId, dayTime, clockTime);
                            }
                        }
                    }
                }

                List<BarberAppointment> appointmentList = barberService.findBarberAppointmentListByDayTime(getBarberId(), dayTime);
                List<AppointmentPartial> appointmentPartialList = AppointmentUtil.getAppointmentPartialList(dayTime, appointmentList);
                result.setAppointmentList(appointmentPartialList);

                result.setResultCode(ResultCode.SUCCESS);
                traceLog.debug(String.format("BarberClientController.myAppointmentBatchset() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, dayTime:%4$d, periodTime:%5$d, activeType:%6$b", ResultCode.SUCCESS, ip, accessToken, dayTime, periodTime, activeType));
            }
            else {
                result.setResultCode(ResultCode.BARBER_CHECKING);
                traceLog.error(String.format("BarberClientController.myAppointmentBatchset() error with BARBER_CHECKING -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, dayTime:%4$d, periodTime:%5$d, activeType:%6$b", ResultCode.BARBER_CHECKING, ip, accessToken, dayTime, periodTime, activeType));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.myAppointmentBatchset() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, dayTime:%4$d, periodTime:%5$d, activeType:%6$b", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, dayTime, periodTime, activeType));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myincome", method= RequestMethod.POST)
    public void myIncome(HttpServletRequest request, HttpServletResponse response) {
        BarberMyIncomeResponse result = new BarberMyIncomeResponse();
        BarberMyIncomeRequest barberMyIncomeRequest = request2Bean(request, BarberMyIncomeRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyIncomeRequest.getAccessToken();
        int pageIndex = barberMyIncomeRequest.getPageIndex();
        int pageSize = barberMyIncomeRequest.getPageSize();

        if(RequestParamChecker.checkPageIndexAndSize(pageIndex, pageSize)){
            long barberId = getBarberId();

            if (barberId > 0){
                if (pageIndex == 0){
                    result.setNewList(true);
                }
                else {
                    result.setNewList(false);
                }

                List<Orders> ordersList = orderService.findBarberOrderList(barberId, OrderStatusType.SERVICED, pageIndex, pageSize);
                List<OrderBarberSummaryPartial> orderBarberSummaryPartialList = new ArrayList<>(ordersList.size());
                for (Orders orders : ordersList){
                    OrderBarberSummaryPartial orderBarberSummaryPartial = new OrderBarberSummaryPartial();
                    orderBarberSummaryPartial.setOrderID(orders.getId());
                    orderBarberSummaryPartial.setOrderName(orders.getOrderName());
                    orderBarberSummaryPartial.setOrderImageUrl(orders.getOrderIcon());
                    orderBarberSummaryPartial.setOrderPrice(orders.getPrice());
                    orderBarberSummaryPartial.setOrderCreateTime(orders.getCreateTime().getTime());

                    orderBarberSummaryPartialList.add(orderBarberSummaryPartial);
                }

                result.setResultCode(ResultCode.SUCCESS);
                result.setOrderBarberPartialList(orderBarberSummaryPartialList);
                traceLog.debug(String.format("BarberClientController.myIncome() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, pageIndex:%4$d, pageSize:%5$d", ResultCode.SUCCESS, ip, accessToken, pageIndex, pageSize));
            }
            else {
                result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
                traceLog.error(String.format("BarberClientController.myIncome() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, pageIndex:%4$d, pageSize:%5$d", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken, pageIndex, pageSize));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.myIncome() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, pageIndex:%4$d, pageSize:%5$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, pageIndex, pageSize));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myincome/total", method= RequestMethod.POST)
    public void myIncomeTotal(HttpServletRequest request, HttpServletResponse response) {
        BarberMyIncomeTotalResponse result = new BarberMyIncomeTotalResponse();
        BarberMyIncomeTotalRequest barberMyIncomeTotalRequest = request2Bean(request, BarberMyIncomeTotalRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyIncomeTotalRequest.getAccessToken();

        long barberId = getBarberId();
        if (barberId > 0){
            LinkedHashMap<Integer, Integer> incomeMap = orderService.findBarberIncomeTotalByMonth(barberId);
            List<IncomeTotalPartial> incomeTotalPartialList = new ArrayList<>();
            Set<Integer> incomeSet = incomeMap.keySet();
            int total = 0;
            for (Integer month : incomeSet){
                if (month > 0){
                    int income = incomeMap.get(month);
                    IncomeTotalPartial incomeTotalPartial = new IncomeTotalPartial();
                    incomeTotalPartial.setTotalDate(month);
                    incomeTotalPartial.setTotalMoney(income);
                    incomeTotalPartialList.add(incomeTotalPartial);

                    total += income;
                }
            }

            result.setTotalMoney(total);
            result.setIncomeTotalPartialList(incomeTotalPartialList);
            result.setResultCode(ResultCode.SUCCESS);
            traceLog.debug(String.format("BarberClientController.myIncomeTotal() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s", ResultCode.SUCCESS, ip, accessToken));
        }
        else {
            result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
            traceLog.error(String.format("BarberClientController.myIncomeTotal() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/mycomment", method= RequestMethod.POST)
    public void myComment(HttpServletRequest request, HttpServletResponse response) {
        BarberMyCommentResponse result = new BarberMyCommentResponse();
        BarberMyCommentRequest barberMyCommentRequest = request2Bean(request, BarberMyCommentRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyCommentRequest.getAccessToken();
        int listOrderType = barberMyCommentRequest.getListOrderType();
        int pageIndex = barberMyCommentRequest.getPageIndex();
        int pageSize = barberMyCommentRequest.getPageSize();

        if((listOrderType>=0 && listOrderType<=2) && RequestParamChecker.checkPageIndexAndSize(pageIndex, pageSize)){
            long barberId = getBarberId();

            if (barberId > 0){
                if (pageIndex == 0){
                    result.setNewList(true);
                }
                else {
                    result.setNewList(false);
                }

                List<BarberComment> barberCommentList;
                if (listOrderType == 0){
                    barberCommentList = barberService.findBarberCommentList(barberId, pageIndex, pageSize);
                }
                else if (listOrderType == 1){
                    barberCommentList = barberService.findBarberCommentList(barberId, pageIndex, pageSize, true);
                }
                else{
                    barberCommentList = barberService.findBarberCommentList(barberId, pageIndex, pageSize, false);
                }
                List<OrderCommentPartial> orderCommentPartialList = new ArrayList<>(barberCommentList.size());
                for (BarberComment barberComment : barberCommentList){
                    OrderCommentPartial orderCommentPartial = new OrderCommentPartial();
                    orderCommentPartial.setCustomName(barberComment.getCustomerName());
                    orderCommentPartial.setCustomAvatar(barberComment.getCustomerAvatar());
                    orderCommentPartial.setCommentContent(barberComment.getCommentText());
                    orderCommentPartial.setCommentImgUrlList(StringUtil.split(barberComment.getCommentImgList(), ";"));
                    orderCommentPartial.setCommentLevel(barberComment.getCommentStar());
                    orderCommentPartial.setCommentTime(barberComment.getCreateTime().getTime());

                    orderCommentPartialList.add(orderCommentPartial);
                }
                result.setResultCode(ResultCode.SUCCESS);
                result.setOrderCommentPartialList(orderCommentPartialList);
                traceLog.debug(String.format("BarberClientController.myComment() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, pageIndex:%4$d, pageSize:%5$d, listOrderType:%6$d", ResultCode.SUCCESS, ip, accessToken, pageIndex, pageSize, listOrderType));
            }
            else {
                result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);
                traceLog.error(String.format("BarberClientController.myComment() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, pageIndex:%4$d, pageSize:%5$d, listOrderType:%6$d", ResultCode.ACCESS_TOKEN_ERROR, ip, accessToken, pageIndex, pageSize, listOrderType));
            }
        }
        else {
            result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);
            traceLog.error(String.format("BarberClientController.myComment() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, pageIndex:%4$d, pageSize:%5$d, listOrderType:%6$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, pageIndex, pageSize, listOrderType));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/myprices", method= RequestMethod.POST)
    public void myPrices(HttpServletRequest request, HttpServletResponse response) {
        BarberMyPricesResponse result = new BarberMyPricesResponse();
        BarberMyPricesRequest barberMyPricesRequest = request2Bean(request, BarberMyPricesRequest.class);

        String ip = getIpAddress(request);
        String accessToken = barberMyPricesRequest.getAccessToken();

        if (isPassedBarber()){
            long barberId = getBarberId();
            Barber barber = barberService.findBarber(barberId);
            List<ShopHairService> shopHairServiceList = shopService.selectShopHairServiceList(barber.getShopId());
            List<PriceMenuItemPartial> priceMenuItemPartialList = new ArrayList<>(shopHairServiceList.size());
            for (ShopHairService shopHairService : shopHairServiceList){
                PriceMenuItemPartial itemPartial = new PriceMenuItemPartial();

                itemPartial.setItemType(shopHairService.getServiceType());
                itemPartial.setItemID(shopHairService.getId());
                itemPartial.setItemName(shopHairService.getServiceName());
                itemPartial.setOriginalPrice(shopHairService.getOriginalPrice());
                itemPartial.setCurrentPrice(shopHairService.getRealPrice());

                if (shopHairService.getServiceType() == HairServiceType.HAIR_CUT){
                    itemPartial.setOriginalPrice(barber.getHairCutOriginalPrice());
                    itemPartial.setCurrentPrice(barber.getHairCutRealPrice());
                }
                else if (shopHairService.getServiceType() == HairServiceType.HAIR_MODELING){
                    itemPartial.setOriginalPrice(barber.getHairModelingOriginalPrice());
                    itemPartial.setCurrentPrice(barber.getHairModelingRealPrice());
                }

                priceMenuItemPartialList.add(itemPartial);
            }

            result.setResultCode(ResultCode.SUCCESS);
            result.setPriceMenu(priceMenuItemPartialList);
            traceLog.debug(String.format("BarberClientController.myPrices() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s", ResultCode.SUCCESS, ip, accessToken));
        }
        else {
            result.setResultCode(ResultCode.BARBER_CHECKING);
            traceLog.error(String.format("BarberClientController.myPrices() error with BARBER_CHECKING -> resultCode:%1$d, ip:%2$s, accessToken:%3$s", ResultCode.BARBER_CHECKING, ip, accessToken));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/order/list", method= RequestMethod.POST)
    public void orderList(HttpServletRequest request, HttpServletResponse response){
        OrderBarberListResponse result = new OrderBarberListResponse();
        OrderBarberListRequest orderBarberListRequest = request2Bean(request, OrderBarberListRequest.class);
        String ip = getIpAddress(request);

        String accessToken = orderBarberListRequest.getAccessToken();
        int orderType = orderBarberListRequest.getOrderType();
        int pageIndex = orderBarberListRequest.getPageIndex();
        int pageSize = orderBarberListRequest.getPageSize();

        long barberId = getBarberId();

        if (barberId > 0){
            boolean checkResult = true;
            if (!(orderType>=0 && orderType <=3)){
                checkResult = false;
            }
            else if (!RequestParamChecker.checkPageIndexAndSize(pageIndex, pageSize)){
                checkResult = false;
            }

            if (checkResult){
                List<Orders> ordersList = orderService.findBarberOrderDetailList(barberId, orderType, pageIndex, pageSize);
                List<OrderBarberListSummaryPartial> orderBarberListSummaryPartialList = new ArrayList<>();
                for (Orders order : ordersList){
                    OrderBarberListSummaryPartial orderBarberListSummaryPartial = new OrderBarberListSummaryPartial();
                    orderBarberListSummaryPartial.setOrderImgUrl(order.getOrderIcon());
                    orderBarberListSummaryPartial.setOrderName(order.getOrderName());
                    orderBarberListSummaryPartial.setBarberId(order.getBarberId());
                    orderBarberListSummaryPartial.setCustomerPhoneNum(order.getCustomerPhoneNumber());
                    orderBarberListSummaryPartial.setShopName(order.getShopName());
                    orderBarberListSummaryPartial.setAddressText(order.getShopAddress());
                    orderBarberListSummaryPartial.setLongitude(String.valueOf(order.getLongitude().doubleValue()));
                    orderBarberListSummaryPartial.setLatitude(String.valueOf(order.getLatitude().doubleValue()));
                    orderBarberListSummaryPartial.setOrderPrice(order.getOriginalPrice());
                    orderBarberListSummaryPartial.setOrderStatus(order.getStatus());
                    orderBarberListSummaryPartial.setOrderCommentStar(order.getCommentStar());
                    orderBarberListSummaryPartial.setOrderCreateTime(order.getCreateTime().getTime());
                    orderBarberListSummaryPartial.setOrderAppointmentDay(String.valueOf(order.getAppointmentDay()));
                    orderBarberListSummaryPartial.setOrderAppointmentClock(order.getAppointmentClock());
                    orderBarberListSummaryPartial.setOrderID(order.getId());

                    orderBarberListSummaryPartialList.add(orderBarberListSummaryPartial);
                }

                result.setResultCode(ResultCode.SUCCESS);
                result.setOrderSummaryList(orderBarberListSummaryPartialList);

                traceLog.debug(String.format("BarberClientController.orderList() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, orderType:%4$d, pageIndex:%5$d, pageSize:%6$d", ResultCode.SUCCESS, ip, accessToken, orderType, pageIndex, pageSize));
            }
            else{
                result.setResultCode(ResultCode.REQUEST_PARAM_ERROR);

                traceLog.error(String.format("BarberClientController.orderList() failed with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, orderType:%4$d, pageIndex:%5$d, pageSize:%6$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, orderType, pageIndex, pageSize));
            }
        }
        else {
            result.setResultCode(ResultCode.ACCESS_TOKEN_ERROR);

            traceLog.error(String.format("BarberClientController.orderList() failed with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, orderType:%4$d, pageIndex:%5$d, pageSize:%6$d", ResultCode.SUCCESS, ip, accessToken, orderType, pageIndex, pageSize));
        }

        bean2Response(response, result);
    }

    @RequestMapping(value="/v1/barber/order/finish", method= RequestMethod.POST)
    public void orderFinish(HttpServletRequest request, HttpServletResponse response) {
        OrderBarberFinishResponse result = new OrderBarberFinishResponse();
        OrderBarberFinishRequest orderBarberFinishRequest = request2Bean(request, OrderBarberFinishRequest.class);

        String ip = getIpAddress(request);
        String accessToken = orderBarberFinishRequest.getAccessToken();
        long orderId = orderBarberFinishRequest.getOrderId();

        if (isPassedBarber()){
            long barberId = getBarberId();

            Orders orders = orderService.findOrdersById(orderId);
            if (orders != null && orders.getBarberId() == barberId && orders.getStatus() == OrderStatusType.PAID){
                orderService.updateOrderServiced(orderId);

                result.setResultCode(ResultCode.SUCCESS);
                result.setOrderId(orderId);
                result.setOrderStatus(OrderStatusType.SERVICED);
                traceLog.debug(String.format("BarberClientController.orderFinish() successful -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, orderId:%4$d", ResultCode.SUCCESS, ip, accessToken, orderId));
            }
            else {
                result.setResultCode(ResultCode.BARBER_CHECKING);
                traceLog.error(String.format("BarberClientController.orderFinish() error with REQUEST_PARAM_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, orderId:%4$d", ResultCode.REQUEST_PARAM_ERROR, ip, accessToken, orderId));
            }
        }
        else {
            result.setResultCode(ResultCode.BARBER_CHECKING);
            traceLog.error(String.format("BarberClientController.orderFinish() error with ACCESS_TOKEN_ERROR -> resultCode:%1$d, ip:%2$s, accessToken:%3$s, orderId:%4$d", ResultCode.BARBER_CHECKING, ip, accessToken, orderId));
        }

        bean2Response(response, result);
    }

    @Override
    protected void bean2Response(HttpServletResponse response, ResponseModelBase responseModel){
        try {
            CustomerTokenHolder.unbindCustomerToken();
            BarberTokenHolder.unbindBarberToken();
            ShopTokenHolder.unbindShopToken();

            response.setContentType("text/html");
            response.setCharacterEncoding("UTF-8");
            String responseText = JsonUtil.bean2Json(responseModel);
            response.getWriter().write(responseText);
        }
        catch (IOException e) {
            traceLog.error(String.format("%1$s.bean2Response() error -> %2$s", this.getClass().getSimpleName(), e.getMessage()));
            e.printStackTrace();
        }
    }

    private long getBarberId(){
        long barberId = 0;

        if (BarberTokenHolder.getCurrentBarberToken() != null){
            barberId = BarberTokenHolder.getCurrentBarberToken().getBarberId();
        }

        return barberId;
    }

    private boolean isPassedBarber(){
        boolean result = false;

        if (BarberTokenHolder.getCurrentBarberToken() != null){
            int status = BarberTokenHolder.getCurrentBarberToken().getStatus();
            if (status == BusinessStatusType.VERIFY_PASSED){
                result = true;
            }
        }

        return result;
    }
}
